<template>
  <div>
    <div class="page-body">
      <!-- <div class="page-body-item page-body-btn">
        <img src="@/assets/app/all.svg" />
      </div>-->
      <div class="page-body-con">
        <app-tabs-item class="page-body-con-item" v-for="item in tabsState.tabList" :key="item.id"
          :data-option="item"></app-tabs-item>
      </div>
      <!-- 全部页面展示 -->
      <div class="page-body-item">
        <el-dropdown placement="bottom-end">
          <div class="page-body-btn">
            <img src="@/assets/app/all.svg" />
          </div>
          <template #dropdown>
            <el-dropdown-menu>
              <div class="page-dropdown">
                <el-dropdown-item v-for="item in tabsState.tabList">
                  <div class="page-dropdown-item"
                    :class="{ 'page-dropdown-item-select': item.id == tabsState.selectTabId }"
                    @click="onClickDropdownItem(item)">{{ item.title }}</div>
                </el-dropdown-item>
              </div>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>

      <!-- 其他操作按钮 -->
      <div class="page-body-item">
        <el-dropdown placement="bottom-end">
          <div class=" page-body-btn">
            <img src="@/assets/app/ellipsis.svg" />
          </div>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>
                <div class="page-dropdown-item" @click="tabsAction.removeOtherTab(tabsState.selectTabId)">关闭其他页面</div>
              </el-dropdown-item>
              <el-dropdown-item>
                <div class="page-dropdown-item" @click="tabsAction.removeAllTab()">关闭全部页面</div>
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, ref, computed } from "vue";
export default defineComponent({
  name: "AppTabs",
})
</script>

<script setup lang="ts">
import { } from "vue";
import { tabsState, tabsAction } from "@/store/tabs";
import AppTabsItem from "../AppTabItem";
import { TabItemClass } from "@/model/AppModel";


/**
 * 点击全部数据
 */
function onClickDropdownItem(item: TabItemClass) {
  tabsAction.selectTab(item.id)
}
</script>

<style lang="less" scoped>
@import url("../../config.less");

.page-body {
  height: 100%;
  display: flex;
  align-items: center;
  padding-left: 5px;
}

.page-body-con {
  display: flex;
  flex-grow: 1;
  height: 100%;
  width: 0;
  overflow: overlay;
  &::-webkit-scrollbar {
    height: 3px;
    background: white;
  }
}

.page-body-con-item {
  flex-shrink: 0;
  height: 100%;
}

.page-body-item {
  flex-shrink: 0;
  flex-basis: 40px;
  background-color: white;
  border-radius: var(--app-border-radius);
  margin-left: 5px;
  height: 40px;

  &:hover {
    background-color: rgba(255, 255, 255, 0.7);
  }
}

.page-body-btn {
  outline: none;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border-radius: var(--app-border-radius);


  img {
    display: block;
    width: 28px;
    height: 28px;
    opacity: 0.5;
  }
}

//全部页面展示
.page-dropdown {
  max-height: 60vh;
  overflow: auto;
}

.page-dropdown-item {
  width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-dropdown-item-select {
  color: var(--primaryColor);
  font-weight: bold;
}
</style>
